﻿#ifndef DATADESIGNERDIALOG_H
#define DATADESIGNERDIALOG_H

#include <QDialog>
#include <QDomDocument>

namespace Ui {
class DataDesignerDialog;
}

class QTreeWidgetItem;
class DataDesignerDialog : public QDialog
{
    Q_OBJECT

public:
    explicit DataDesignerDialog(QWidget *parent = nullptr);
    ~DataDesignerDialog();

    // 根据配置初始化
    void initDataItems();

    // 数据对象关系保存到配置文件
    void saveDataConfig();

    void generateCode();

private slots:

private:
    void generateProFile(const QString& path,const QString& name);
    void generateByTreeItem(QTreeWidgetItem* pTreeItem,const QString& path);
    void generateDataControlHeader(const QString& path,const QString& className);
    void generateDataControlCpp(const QString& path,const QString& className);
    void generateDataObjectHeader(const QString& path,const QString& className);
    void generateDataObjectCpp(const QString& path,const QString& className);

    void saveItemToNode(QTreeWidgetItem* pTreeItem,QDomDocument doc,QDomElement node);
    void loadXmlNode(QTreeWidgetItem* pParentItem,QDomElement parNode);

    QVector<QTreeWidgetItem*> getAllCheckedItem(QTreeWidgetItem* parItem);
private:
    Ui::DataDesignerDialog *ui;
};

#endif // DATADESIGNERDIALOG_H
